﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Fly.Net.Static
{
    public class MemoryCache : Fly.Net.Static.ICache
    {
        Dictionary<string, StaticPage> _pages = new Dictionary<string, StaticPage>();

        public virtual Dictionary<string, StaticPage> Pages { get { return _pages; } }

        public virtual StaticPage Get(string key, string version)
        {
            StaticPage page = null;
            if (Pages.TryGetValue(key, out page))
            {
                if (page.Version == version)
                {
                    return page;
                }
            }
            return null;
        }

        public virtual void Set(string key, StaticPage page)
        {
            this.Pages[key] = page;
        }
    }
}
